<?php

require_once 'common/conn.php';

$usercode = $_GET['usercode'];
if (!isset($usercode)) {
    $usercode = $_POST['usercode'];
}

$month = date("Y-m-d");
$db = new DBC();
$sql = "SELECT packid,name,soundURL,imageURL,ImageAid1URL,ImageAid2URL,year,month,age  FROM t_pack WHERE year = YEAR('" . $month . "') AND month = MONTH('".$month."') AND age = (SELECT age FROM t_device WHERE devicecode = '" . $usercode . "')";
$data = $db->fetchData($sql);
$result = array();
$result['packs'] = $data;

$sql = "SELECT * FROM t_product WHERE year = YEAR('" . $month . "') AND month = MONTH('".$month."') AND type3 = 'music'";
$data = $db->fetchData($sql);
$result['music'] = $data;
echo json_encode($result);
?>
